Skip to content

feat(layout): block-level horizontal alignment for fixed-size flow children#183

Merged
DemchaAV merged 1 commit into
developfrom
feat/block-align
Jun 13, 2026
Merged

feat(layout): block-level horizontal alignment for fixed-size flow children#183
DemchaAV merged 1 commit into
developfrom
feat/block-align

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Closes the recurring "how do I centre an SVG icon?" friction (hit on the gallery, the костыль discussion, and again now) — the roadmap's block-level alignment item (#178).

What

Fixed-size flow children (paths, images, SVG icons, barcodes, shape containers) left-align by default; there was no built-in way to centre or right-align one without wrapping it in a full-width container and hand-computing pageWidth − margins.

  • HorizontalAlign (LEFT / CENTER / RIGHT) + AlignNode — fills the available content width and seats its single child via the existing stack placement engine (one anchor). No new render handler (emitFragments is empty), no hot-path change.
  • DSL: flow.addAligned(align, node) for any fixed node, plus the icon sugar flow.addSvgIcon(icon, width, align).
flow.addSvgIcon(icon, 44, HorizontalAlign.CENTER);   // centre an icon, one call
flow.addAligned(HorizontalAlign.RIGHT, anyFixedNode); // works for paths, images, …

Verification

  • ./mvnw verify -pl .BUILD SUCCESS, +5 tests pinning exact placement x for LEFT (=margin), CENTER (=margin + (content−w)/2), RIGHT (=margin + content−w), plus the icon overload — they catch any regression in the offset math, not just "it renders".
  • New BlockAlignExample (caption=API / body=result), registered in GenerateAllExamples + ShowcaseMetadata, README row + section; block-align.pdf committed. Proof render shows one mark left / centre / right on the page.

Self-reviewed (six lanes). Architecture: HorizontalAlign is a pure semantic enum — the LayerAlign mapping lives in the layout layer, not the public node API. Independent of any open branch — clean off develop.

…ildren

Fixed-size flow children (paths, images, SVG icons, barcodes) left-align by
default; centring one meant wrapping it in a full-width container and
hand-computing the content width (the recurring friction behind the
roadmap item).

- HorizontalAlign (LEFT/CENTER/RIGHT) + AlignNode: fills the available
  width and seats its single child via the existing stack placement engine
  (one anchor) — no new render handler, no hot-path change
- DSL: addAligned(align, node) for any fixed node, plus the icon sugar
  addSvgIcon(icon, width, align)
- BlockAlignExample (caption=API / body=result), registered + README row
- 5 tests pinning exact placement x for LEFT/CENTER/RIGHT + the icon overload
@DemchaAV DemchaAV merged commit 331bc95 into develop Jun 13, 2026
11 checks passed
@DemchaAV DemchaAV deleted the feat/block-align branch June 13, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant